package com.webserver.http;

import java.io.IOException;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

public class HttpServletRequest {
    private Socket socket;
    //请求行的相关信息
    private String method;
    private String uri;
    private String protocol;

    private Map<String,String>headers=new HashMap<>();

    public HttpServletRequest(Socket socket){
        this.socket=socket;
        //解析请求行
        parseRequestLine();
        //解析消息头
        parseHeaders();
        //解析消息正文
        parseContent();
    }

    private void parseContent() {

    }


    private void parseHeaders() {

    }

    private void parseRequestLine() throws IOException {
        String line=readline();
        System.out.println("请求行内容"+line);
        String[] data=line.split("\\s");
        method =data[0];
        uri =data[1];
        protocol=data[2];
        System.out.println("method"+method);
        System.out.println("uri"+uri);
        System.out.println("protocol"+protocol);
    }

}
